package com.hongyuan.sellfitness.ui.person.view_mode;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.ItemViewModel;
import com.hongyuan.sellfitness.ui.person.beans.CouponHubBean;

public class CouponHubItemViewModel extends ItemViewModel<FragmentCouponHubViewModel> {

    public ObservableField<CouponHubBean.ListBean> entity = new ObservableField<>();

    public CouponHubItemViewModel(@NonNull FragmentCouponHubViewModel viewModel, CouponHubBean.ListBean bean) {
        super(viewModel);
        entity.set(bean);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            if(entity.get().isReceive()){
                viewModel.itemClick(CouponHubItemViewModel.this);

                viewModel.setParams("coupon_id",String.valueOf(entity.get().getCoupon_id()));
                viewModel.requestData(Constants.GET_COUPON);
            }
        }
    });

}
